<%! func Search(w io.Writer,r *http.Request,q string,filter string,from int,size int,config *common.UIConfig, response *elastic.SearchResponse) error %>
<%% import "net/http" %%>
<%% import "github.com/infinitbyte/gopa/ui/search/common" %%>
<%% import "github.com/infinitbyte/framework/core/elastic" %%>
<%% import "github.com/infinitbyte/framework/core/util" %%>
<%% import "fmt" %%>

<!DOCTYPE html>
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en-US"> <![endif]-->
<!--[if IE 7 ]>    <html class="no-js ie7" lang="en-US"> <![endif]-->
<!--[if IE 8 ]>    <html class="no-js ie8" lang="en-US"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html lang="en-US" class="uk-touch"> <!--<![endif]-->

<head>
    <title><%= q %> | <%= config.SiteName %></title>
    <% CommonHeader(w,config) %>
</head>
<body link="#0000cc">

<style>
    #out {
        width: 100%;
        min-width: 200px;
    }

    #out #head{
        width: 100%;
        background: #f6f6f6;
        padding-bottom: 20px;
        border-bottom: 1px solid #ebebeb;
    }

    #out .nv {
        height: auto;
        padding-left:10px;
    }

    #out .logo{
        padding-right: 10px;
    }

    #out .logo>img{
        padding:5px 0 0 0;
        max-width: 400px;
        height: 50px;
        max-height: 50px;
    }

    #out .toolbar_wrapper-m {
        /*padding: 0 10px;*/
        padding-top: 0!important;
        padding-bottom: 10px;
        padding-left: 10px;
        padding-right: 10px;
    }

    #out .sbx-custom {
        width: 100%;
        max-width:500px;
        height:41px;
        margin-top:10px;
    }

    #out #container {
        padding:0 10px;
    }

    #out #container .result{
        width: 100%;
        margin-top: 8px;
        border-bottom: 1px solid #e6e6e6;
        padding-bottom: 8px;
    }

    #out #container .f{
        width: 100%;
    }

    #out #container .t{
        width: 100%;
    }

</style>

<div id="out">
    <div id="in">
        <div id="wrapper">
            <div id="head">

                <div id="toolbar_wrapper" class="toolbar_wrapper-m" style="top: 0px; left: 0px; z-index: 999; padding-top: 10px; right: 0px;">
                    <a class="logo" href="/">
                        <img border="0" alt="<%= config.SiteName %>" title="" src="<%= config.SiteLogo %>">
                    </a>
                    <svg xmlns="http://www.w3.org/2000/svg" style="display:none">
                        <symbol xmlns="http://www.w3.org/2000/svg" id="sbx-icon-search-6" viewBox="0 0 40 40">
                            <path d="M28.295 32.517c-2.93 2.086-6.51 3.312-10.38 3.312C8.02 35.83 0 27.81 0 17.914 0 8.02 8.02 0 17.915 0 27.81 0 35.83 8.02 35.83 17.915c0 3.87-1.227 7.45-3.313 10.38l6.61 6.61c1.166 1.165 1.163 3.057 0 4.22-1.167 1.167-3.057 1.167-4.226-.002l-6.605-6.606zm-10.38.326c8.245 0 14.928-6.683 14.928-14.928 0-8.245-6.683-14.93-14.928-14.93-8.245 0-14.93 6.685-14.93 14.93 0 8.245 6.685 14.928 14.93 14.928zm0-26.573c-6.43 0-11.645 5.214-11.645 11.645 0 .494.4.895.896.895.495 0 .896-.4.896-.895 0-5.442 4.41-9.853 9.853-9.853.494 0 .895-.4.895-.896 0-.495-.4-.896-.895-.896z" fill-rule="evenodd"></path>
                        </symbol>
                        <symbol xmlns="http://www.w3.org/2000/svg" id="sbx-icon-clear-3" viewBox="0 0 20 20">
                            <path d="M8.114 10L.944 2.83 0 1.885 1.886 0l.943.943L10 8.113l7.17-7.17.944-.943L20 1.886l-.943.943-7.17 7.17 7.17 7.17.943.944L18.114 20l-.943-.943-7.17-7.17-7.17 7.17-.944.943L0 18.114l.943-.943L8.113 10z" fill-rule="evenodd"></path>
                        </symbol>
                    </svg>

                    <form name="f" id="f" novalidate="novalidate" class="searchbox sbx-custom" action="/m/" onsubmit="submitSearch()">
                        <div role="search" class="sbx-custom__wrapper">
                            <input type="q" name="q"
                                   placeholder="Please type to search ..."
                                   value="<%= q %>"                                       autocomplete="off" required="required"
                                   id="query" maxLength=100 role="textbox"
                                   accesskey="s" type="text" x-webkit-speech="" speech="" spellcheck="false" autocomplete="off"
                                   class="sbx-custom__input" >
                            <button type="submit" title="Submit your search query." class="sbx-custom__submit">
                                <svg role="img" aria-label="Search">
                                    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sbx-icon-search-6"></use>
                                </svg>
                            </button>
                            <button type="reset" title="Clear the search query." class="sbx-custom__reset">
                                <svg role="img" aria-label="Reset">
                                    <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#sbx-icon-clear-3"></use>
                                </svg>
                            </button>
                        </div>
                    </form>

                </div>
                <div id="toolbar_baseline" class="toolbar_baseline"></div>
                <div style="padding-bottom: 5px;padding-left:10px;">
                    <SPAN style="float: left;" class=nums>About <%= response.GetTotal() %> results (<span><%= response.Took %>ms</span>)</SPAN>
                </div>
            </div>
            <div id="container">

                <div style=" width: auto;clear: both;">

                    <!--filter begin-->
                    <div class="item-view">
                        <%
                        hasResult:= len(response.Hits.Hits)>0
                        if hasResult { %>
                        <% Block(w,r,q ,filter ,from ,size ,config , response ) %>
                        <%
                        }else{%>
                        <div class="uk-alert uk-alert-warning"> Nothing found.</div>
                        <%}%>

                    </div>
                    <!--filter end-->

                    <%
                    if hasResult && response.GetTotal()>10 {
                    %>
                    <div class="loadmore">
                        <div class="pnnext" data-total="<%= response.GetTotal() %>" data-from="<%= from %>" data-size="<%= size %>" data-load-text="Loading ...">
                            <span class="load-icon"></span><span class="load-text">Load More</span>
                        </div>
                        <p class="load-tips"></p>
                    </div>
                    <%
                    }%>

                    <div class="c-back">
                        <div class="back-top">
                            <svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="519">
                                <path d="M873.6 419.2l-355.2-361.6c-9.6-9.6-22.4-9.6-32 0l-355.2 368c-9.6 9.6-9.6 22.4 0 32 9.6 9.6 22.4 9.6 32 0l316.8-329.6 0 828.8c0 12.8 9.6 22.4 22.4 22.4s22.4-9.6 22.4-22.4l0-822.4 310.4 316.8c9.6 9.6 22.4 9.6 32 0C883.2 441.6 883.2 425.6 873.6 419.2z" p-id="520">
                                </path>
                            </svg>
                        </div>
                    </div>
                </div>

                <div class="copyright">
                    <% common.Copyright(w,config) %>
                </div>

            </div>

        </div>
    </div>


</div>

<% CommonFooter(w) %>

</body>
</html>
